package com.sttk.fastMark.camera.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sttk.fastMark.camera.R;
import com.sttk.fastMark.camera.basic.ProviderMultiAdapter;
import com.sttk.fastMark.camera.bean.WatermarkBean;


public class WatermarkAdapter extends ProviderMultiAdapter<WatermarkBean> {

    private int selPosition;

    public WatermarkAdapter() {
        addItemProvider(new ColorProvider());
    }

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
        notifyDataSetChanged();
    }

    private class ColorProvider extends BaseItemProvider<WatermarkBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_watermark;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, WatermarkBean bean) {
            baseViewHolder.setImageResource(R.id.ivWatermarkItemImg, bean.getImg());
            if (selPosition == baseViewHolder.getBindingAdapterPosition()) {
                baseViewHolder.getView(R.id.ivWatermarkItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivWatermarkItemSel).setVisibility(View.GONE);
            }
        }
    }

}
